<template>
  <div>
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="入库单号查询" name="1">
        <el-form :inline="true" size="mini" :model="formInline" class="demo-form-inline">
          <el-form-item label="血袋序号">
            <el-input v-model="formInline.xdnumber" placeholder="血袋序号"></el-input>
          </el-form-item>
          <el-form-item label="血袋编号">
            <el-input v-model="formInline.rkdh" placeholder="血袋编号"></el-input>
          </el-form-item>
          <!-- <el-form-item>
            <el-checkbox v-model="formInline.checked">回收信息可修改</el-checkbox>
          </el-form-item>-->
          <el-form-item>
            <el-button @click="getrkcx">查询</el-button>
            <el-button>血袋回收</el-button>
            <el-button>回收撤回</el-button>
            <el-button>血袋销毁</el-button>
            <el-button>纵向打印</el-button>
            <el-button>打印</el-button>
            <el-button>清空数据</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="入库时间查询" name="2">
        <el-form :inline="true" size="mini" :model="formInline" class="demo-form-inline">
          <el-form-item label="入库日期">
            <el-date-picker
              v-model="formInline.date"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
          <!-- <el-form-item>
            <el-checkbox v-model="formInline.checked">回收信息可修改</el-checkbox>
          </el-form-item>-->
          <el-form-item>
            <el-button @click="getrkcx">查询</el-button>
            <!-- <el-button>回收撤回</el-button>
            <el-button>血袋销毁</el-button>
            <el-button>纵向打印</el-button>
            <el-button>打印</el-button>
            <el-button>清空数据</el-button>-->
          </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
    <el-table :data="tableData" height="250" border style="width: 100%;margin-bottom:15px">
      <el-table-column fixed prop="id" label="ID" width="50"></el-table-column>
      <el-table-column fixed prop="xymc" label="血液名称" width="300"></el-table-column>
      <el-table-column prop="aboxx" label="ABO血型" width="120"></el-table-column>
      <el-table-column prop="cgj" label="采购价" width="120"></el-table-column>
      <el-table-column prop="dw" label="单位" width="50"></el-table-column>
      <el-table-column prop="gg" label="规格" width="60"></el-table-column>
      <el-table-column prop="cjrq" label="采集日期" width="200"></el-table-column>
      <el-table-column prop="ccwz" label="存放位置" width="80"></el-table-column>
      <el-table-column prop="bqwz" label="标签完整" width="80"></el-table-column>
      <el-table-column prop="jjczymc" label="交接人" width="80"></el-table-column>
      <el-table-column prop="mfx" label="密封性" width="80"></el-table-column>
      <el-table-column prop="rkczymc" label="入库人"></el-table-column>
      <el-table-column prop="sfck" label="是否出库"></el-table-column>
      <el-table-column prop="sfzf" label="是否作废"></el-table-column>
      <el-table-column prop="yswd" label="运输温度℃" width="100"></el-table-column>
      <el-table-column prop="yxq" label="有效期" width="200"></el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="insertDiag(scope.row,0)" type="text" size="small">回收</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-pagination
      class="block"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
    ></el-pagination>-->
    <el-tabs v-model="activexh" type="card">
      <el-tab-pane label="血袋销毁单号查询" name="1">
        <el-form :inline="true" size="mini" :model="xhForm" class="demo-form-inline">
          <el-form-item label="血袋序号">
            <el-input v-model="xhForm.xdnumber" placeholder="血袋序号"></el-input>
          </el-form-item>
          <el-form-item label="血袋编号">
            <el-input v-model="xhForm.rkdh" placeholder="血袋编号"></el-input>
          </el-form-item>
          <!-- <el-form-item>
            <el-checkbox v-model="formInline.checked">回收信息可修改</el-checkbox>
          </el-form-item>-->
          <el-form-item>
            <el-button @click="getxdhsxh">查询</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="血袋回收时间查询" name="2">
        <el-form :inline="true" size="mini" :model="xhForm" class="demo-form-inline">
          <el-form-item label="入库日期">
            <el-date-picker
              v-model="xhForm.date"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
          <!-- <el-form-item>
            <el-checkbox v-model="formInline.checked">回收信息可修改</el-checkbox>
          </el-form-item>-->
          <el-form-item>
            <el-button @click="getxdhsxh">查询</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="血袋销毁时间查询" name="3">
        <el-form :inline="true" size="mini" :model="xhForm" class="demo-form-inline">
          <el-form-item label="入库日期">
            <el-date-picker
              v-model="xhForm.date"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
          <!-- <el-form-item>
            <el-checkbox v-model="formInline.checked">回收信息可修改</el-checkbox>
          </el-form-item>-->
          <el-form-item>
            <el-button @click="getxdhsxh">查询</el-button>
          </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
    <el-table :data="tableDataXh" height="250" border style="width: 100%">
      <el-table-column fixed prop="id" label="ID" width="50"></el-table-column>
      <el-table-column prop="hsczymc" label="回收操作员" width="200"></el-table-column>
      <el-table-column prop="hsrq" label="回收日期"></el-table-column>
      <el-table-column prop="sfhs" label="是否回收"></el-table-column>
      <el-table-column prop="sfhszf" label="是否回收作废"></el-table-column>
      <el-table-column prop="sfxh" label="是否销毁"></el-table-column>
      <el-table-column prop="sfxhzf" label="是否销毁作废"></el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="insertDiag(scope.row,1)" type="text" size="small">销毁</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
      <el-form ref="form" :model="diagForm" label-width="100px">
        <el-form-item :label="diagFormrq">
          <el-date-picker v-model="diagForm.hsrq" type="datetime" placeholder="选择日期时间"></el-date-picker>
        </el-form-item>
        <el-form-item :label="diagFormczy">
          <el-input disabled v-model="diagForm.hsy"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="insertxdhs()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getDate } from "../js/unit";
export default {
  data() {
    return {
      formInline: {
        xdnumber: "",
        region: "",
        checked: false,
        date: [],
        rkdh: "202008000036",
      },
      tableData: [],
      currentPage: 4,
      activeName: "1",
      dialogVisible: false,
      diagForm: {
        hsrq: "",
        hsy: this.$cookies.get("userInfo").username,
      },
      activexh: "1",
      xhForm: {
        xdnumber: "",
        region: "",
        checked: false,
        date: [],
        rkdh: "202008000036",
      },
      tableDataXh: [],
      diagFormrq: "",
      diagFormczy: "",
      diagType: 0,
    };
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    //获取列表
    getkcxx() {
      this.$ajax.get(`/xk/getkcxx`, {}).then((res) => {
        this.tableData = res.data;
      });
    },
    //获取回收列表
    getrkcx() {
      let data;
      if (this.activeName == "1") {
        data = {
          lb: this.activeName,
          rkdh: this.formInline.rkdh,
        };
      } else {
        data = {
          lb: this.activeName,
          rkjsrq: this.formInline.date[0],
          rkksrq: this.formInline.date[1],
        };
      }
      this.$ajax.get(`/xk/getrkcx`, data).then((res) => {
        this.tableData = res.data;
      });
    },
    //获取销毁列表
    getxdhsxh() {
      let data;
      if (this.activexh == "1") {
        data = {
          lb: this.activexh,
          xdh: this.xhForm.rkdh,
          xdhnumber: this.xhForm.xdnumber,
        };
      } else {
        data = {
          lb: this.activexh,
          jsrq: this.xhForm.date[0],
          ksrq: this.xhForm.date[1],
        };
      }
      this.$ajax.get(`/xk/getxdhsxh`, data).then((res) => {
        this.tableDataXh = res.data;
      });
    },
    insertxdhs(row) {
      if (this.diagType == 0) {
        let data = {
          hsbz: "1",
          hsczy: this.$cookies.get("userInfo").account,
          hsrq: this.diagForm.hsrq,
          xdh: this.formInline.rkdh,
          xdhnumber: this.formInline.xdnumber,
        };
        this.$ajax.post(`/xk/insertxdhs`, data).then((res) => {
          if (res.code == "1") {
            this.$message.error(res.msg);
          } else {
            this.$message({
              message: "回收成功",
              type: "success",
            });
            this.dialogVisible = false;
            this.getrkcx();
          }
        });
      } else {
        let data = {
          xhbz: "1",
          xhczy: this.$cookies.get("userInfo").account,
          xhrq: this.diagForm.hsrq,
          xdh: this.formInline.rkdh,
          xdhnumber: this.formInline.xdnumber,
        };
        this.$ajax.post(`/xk/insertxdxh`, data).then((res) => {
          if (res.code == "1") {
            this.$message.error(res.msg);
          } else {
            this.$message({
              message: "销毁成功",
              type: "success",
            });
            this.dialogVisible = false;
            this.getxdhsxh();
          }
        });
      }
    },
    insertDiag(row, type) {
      this.dialogVisible = true;
      this.diagForm.hsrq = getDate();
      this.diagType = type;
      if (type == 0) {
        this.diagFormrq = "回收日期";
        this.diagFormczy = "回收操作员";
      } else {
        this.diagFormrq = "销毁日期";
        this.diagFormczy = "销毁操作员";
      }
    },
    //销毁
    insertxdxh(row) {},
  },
  mounted() {
    // this.getkcxx();
  },
};
</script>
<style lang="less" scoped>
.block {
  margin-top: 3px;
}
.box-card {
  margin-bottom: 5px;
}
</style>    